﻿#include "CVideoEnlargeDlg.h"
#include "CHeader.h"

CVideoEnlargeDlg::CVideoEnlargeDlg(QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	m_pCamerCtrMange = nullptr;
	m_pDev = nullptr;
	m_nType = 0;
	m_nCreateType = 0;
	setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
	Qt::WindowFlags flags = this->windowFlags();
	this->setWindowFlags(flags&~Qt::WindowContextHelpButtonHint);
}

CVideoEnlargeDlg::~CVideoEnlargeDlg()
{
	if (m_nCreateType == 0)
	{
		if (m_nType == 0)
		{
			SCtrInfo info;
			info.m_bCtrSync = false;
			info.m_hHwnd = (HWND)ui.label->winId();
			info.m_nCtrCmd = enCStopRealPlay;
			info.m_nSubCtrDevType = enCamer;
			info.m_sCtrId = "enCamer";
			bool bRet = m_pCamerCtrMange->ctrDevice(info);
		}
		else if (m_nType == 1)
		{
			SCtrInfo info;
			info.m_bCtrSync = false;
			info.m_hHwnd = (HWND)ui.label->winId();
			info.m_nCtrCmd = enCStopRealPlay;
			info.m_nSubCtrDevType = enIR;
			info.m_sCtrId = "IR";
			bool bRet = m_pCamerCtrMange->ctrDevice(info);
		}
	}
	else if (m_nCreateType == 1)
	{
		if (m_nType == 0)
		{
			SCtrInfo info;
			info.m_bCtrSync = false;
			info.m_bHasCtr = false;
			info.m_pLabel = ui.label;
			info.m_hHwnd = (HWND)ui.label->winId();
			info.m_nCtrCmd = enCStopRealPlay;
			info.m_nSubCtrDevType = enCamer;
			info.m_nCtrDevType = enSubDev1;
			m_pDev->ctrDev(info);
		}
		else if (m_nType == 1)
		{
			SCtrInfo info;
			info.m_bHasCtr = false;
			info.m_bCtrSync = false;
			info.m_pLabel = ui.label;
			info.m_hHwnd = (HWND)ui.label->winId();
			info.m_nCtrCmd = enCStopRealPlay;
			info.m_nSubCtrDevType = enIR;
			info.m_nCtrDevType = enSubDev1;
			m_pDev->ctrDev(info);
		}
	}
}

void CVideoEnlargeDlg::platVideo()
{
	if (m_pCamerCtrMange)
	{
		if (m_nType == 0)
		{
			//修改标题
			this->setWindowTitle(A2T("图像相机预览"));
			SCtrInfo info;
			info.m_hHwnd = (HWND)ui.label->winId();
			info.m_pLabel = ui.label;
			info.m_bCtrSync = false;
			info.m_nCtrCmd = enCRealPlay;
			info.m_nSubCtrDevType = enCamer;
			info.m_sCtrId = "CAMER";
			bool bRet = m_pCamerCtrMange->ctrDevice(info);
		}
		else if (m_nType == 1)
		{
			this->setWindowTitle(A2T("红外相机预览"));
			SCtrInfo info;
			info.m_bCtrSync = false;
			info.m_hHwnd = (HWND)ui.label->winId();
			info.m_pLabel = ui.label;
			info.m_nCtrCmd = enCRealPlay;
			info.m_nSubCtrDevType = enIR;
			info.m_sCtrId = "IR";
			bool bRet = m_pCamerCtrMange->ctrDevice(info);
		}
	}
}

void CVideoEnlargeDlg::playVideoByIFDev()
{
	if (m_pDev)
	{
		if (m_nType == 0)
		{
			//修改标题
			this->setWindowTitle(A2T("图像相机预览"));
			SCtrInfo infoTx;
			infoTx.m_bCtrSync = false;
			infoTx.m_pLabel = ui.label;
			infoTx.m_hHwnd = (HWND)ui.label->winId();
			infoTx.m_bHasCtr = false;
			infoTx.m_nCtrCmd = enCRealPlay;
			infoTx.m_nCtrDevType = enSubDev1;
			infoTx.m_nSubCtrDevType = enCamer;
			bool bRet=m_pDev->ctrDev(infoTx);
			if (bRet == false)
			{
				
			}

		}
		else if (m_nType == 1)
		{
			this->setWindowTitle(A2T("红外相机预览"));
			SCtrInfo infoHw;
			infoHw.m_bCtrSync = false;
			infoHw.m_pLabel = ui.label;
			infoHw.m_hHwnd = (HWND)ui.label->winId();
			infoHw.m_bHasCtr = false;
			infoHw.m_nCtrCmd = enCRealPlay;
			infoHw.m_nCtrDevType = enSubDev1;
			infoHw.m_nSubCtrDevType = enIR;
			bool bRet=m_pDev->ctrDev(infoHw);
			if (bRet == false)
			{

			}
		}
	}
}
